package com.example.security_demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.security_demo.dao.UserDao;
import com.example.security_demo.pojo.User;
import com.example.security_demo.pojo.UserVo;
import com.example.security_demo.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *
 *
 * @author zzh
 * @date 2022/5/11
 * @since 1.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;


    @Override
    public User getUserByMobile(String mobile) {
        // TODO 对电话号码进行验证
        return userDao.selectOne(new QueryWrapper<User>().eq("mobile", mobile));
    }

    @Override
    public UserVo loadUserByUsername(String username) {
        User user = getUserByMobile(username);
        UserVo userVo = new UserVo(user);
        userVo.setUserName(username);
        return userVo;
    }


}
